<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
111
</body>
<script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>

<script>
    let url = "http://baidu.com?a=1_其他:华为&a=2_inter:amd&c=3";
    let s = url.substr(url.indexOf("?")+1);
    let regExp = new RegExp("(^|&)a=([^&]*)(|&$)");

    console.log(s.match(regExp));

    function getQueryArr(name){
        let url = "http://baidu.com?a=1_其他:华为&a=2_inter:amd";
        let reg = new RegExp("(^|&)"+name+"=([^&]*)(|&$)","g");
        let r = url.substr(url.indexOf("?")+1);
        let res = [...r.matchAll(reg)];
        let arr = [];
        console.log(r,res,reg);
        if(res.length == 0) return null;
        for(let i=0; i<res.length;i++){
            arr[i] = res[i][2];
        }
        return arr;
    }
    console.log(getQueryArr("a"));


    var arr1 = [1, 2, 3, 4];
    var sum = arr1.reduce(function(prev, cur, index, arr) {
        console.log(prev, cur, index);
        return prev + cur;
    })
    console.log(arr1, sum);
</script>

</html>